﻿using AuApmt.Utils;
using Microsoft.EntityFrameworkCore;

namespace AuApmt.Models.Db.Context.Specific
{
    public class DataSqliteContext(
        DataContextOptions options
        ) : DataContext(options)
    {
        protected override string AcceptDbType => "sqlite";
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            var path = SqliteConnStrParser.GetDataSource(_options.ConnStr);
            FileInfo f = new(path);
            if (f.Directory is { } && !f.Directory.Exists)
                f.Directory.Create();
            optionsBuilder.UseSqlite(_options.ConnStr);
        }
    }
}
